module queue_operators ;
     int q[$] = { 2, 4, 8 };
     int p[$];
     int e, pos;
initial
begin
     $display("%0d_", q);

     e = q[0];              //  read the first (leftmost) item
     e = q[$];              //  read the last (rightmost) item
     q[0] = e;              //  write the first item

     p = q;                 //  read and write entire queue (copy)
     $display("%0d_", q);

     q = { q, 6 };          // insert '6' at the end (append 6)
     $display("%0d_", q);

     q = { e, q };          // insert 'e' at the beginning (prepend e)
     $display("%0d_", q);

     q = q[1:$];            // delete the first (leftmost) item
     $display("%0d_", q);

     q = q[0:$-1];          // delete the last (rightmost) item
     $display("%0d_", q);

     q = q[1:$-1];          // delete the first and last items
     $display("%0d_", q);

     q = {};                // clear the queue (delete all items)
     $display("%0d_", q);

     pos = 2 ;
     q = { q[0:pos-1], 22,  q[pos:$] };   // insert 'e' at position pos
     $display("%0d_", q);
     
     q = { q[0:pos], 66, q[pos+1:$] };   // insert 'e' after position pos
     $display("%0d_", q);
end

endmodule
